﻿using System;
using System.Timers;

namespace EventLearn
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Timer timer = new Timer(1000);

            Boy w2 = new Boy();
            w2.Name = "王二";
            timer.Elapsed += w2.Dump;

            Boy b1 = new Boy();
            b1.Name = "张三";
            timer.Elapsed += b1.Jump;

            Girl g1 = new Girl();
            g1.Name = "小花";
            timer.Elapsed += g1.Fighting;

            timer.Start();

            Console.ReadLine();
            Console.WriteLine("张三累了，不跳了");
            timer.Elapsed -= b1.Jump;

            Console.ReadLine();
        }

        public class Boy
        {
            public string Name { get; set; }
            public void Jump(object sender, ElapsedEventArgs e)
            {
                Console.WriteLine($"男生{Name}：跳");
            }
            public void Dump(object sender, ElapsedEventArgs e)
            {
                Console.WriteLine($"男生{Name}：敲鼓");
            }
        }
        public class Girl
        {
            public string Name { get; set; }
            public void Fighting(object sender, ElapsedEventArgs e)
            {
                Console.WriteLine($"女生{Name}说：加油");
            }
        }

    }
}
